const button = document.createElement("button");
console.log('按钮')
button.innerHTML = "屏幕浏览器录制";
button.style = "position: fixed; top:100px; z-index: 999999;";
document.body.append(button);
button.addEventListener("click", async () => {
  const stream = await navigator.mediaDevices.getDisplayMedia();
  const recoder = new MediaRecorder(stream);
  recoder.start();
  const [video] = stream.getVideoTracks();
  video.addEventListener("ended", () => {
    recoder.stop();
  });
  recoder.addEventListener("dataavailable", (evt) => {
    const a = document.createElement("a");
    a.href = URL.createObjectURL(evt.data);
    a.download = "video.mp4";
    a.click();
  });
});